package org.cxn.tools.commons.poi.excel;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;

/**
 * Created by IntelliJ IDEA.
 * User: lenovo
 * Date: 11-12-21
 * Time: 下午4:43
 * To change this template use File | Settings | File Templates.
 */
public class MyHSSFRow {

    /**
     * 创建一行,之所以二次封装是由于绝大部分数字都从0开始.不太直观
     * @param sheet
     * @param row
     * @return
     */
    public final Row createRow(Sheet sheet, int row){
        return sheet.createRow(row-1);
    }

    /**
     * 设置行高度
     * @param row
     * @param height
     */
    public final void setHeightInPoints(Row row, float height){
        row.setHeightInPoints(height);
    }



    private MyHSSFRow() {
    }

    /**
     * 类级的内部类,也就是静态的成员式内部类,该内部类的实例与外部类的实例
     * 没有绑定关系,而且只有被调用到才会装载,从而实现了延迟加载.
     */
    private static class SingletonHolder {
        /**
         * 静态初始化器,由JVM来保证线程安全
         */
        private static MyHSSFRow row = new MyHSSFRow();
    }

    public final static MyHSSFRow getInstance() {
        return SingletonHolder.row;
    }
}
